'use strict';

var mongoose = require('mongoose'),
    Schema = mongoose.Schema;

var ProjectSchema = new Schema({
  name: {type: String, required: true},
  leader: {
    type: Schema.Types.ObjectId,
    ref: 'User'
  },
  joiners: [{
    type: Schema.Types.ObjectId,
    ref: 'User'
  }],
  departments: [{
    type: Schema.Types.ObjectId,
    ref: 'Department'
  }],
  type: {type: String, required: true},
  start_date: {type: Date, required: true},
  end_date: Date,
  progress: String,
  is_completed: {type: Boolean, default: false},
  files: [{
      type: Schema.Types.ObjectId,
      ref: 'Document'
  }],
  created_at: {type: Date, default: Date.now},
  updated_at: {type: Date, default: Date.now}
});

module.exports = mongoose.model('Project', ProjectSchema);
